home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 031a / wb613_01.zip / BOSSDEMO.C < prev    next >
Text File  |  1991-10-29  |  31KB  |  903 lines

  1. /*
  2. ** Demo for The Window Boss
  3. **
  4. ** Copyright (c) 1985-1990 - Philip A. Mongelluzzo
  5. ** All rights reserved.
  6. **
  7. */
  8.  
  9. #include "winboss.h"                    /* windows header file */
  10.  
  11. #if DLC
  12. int _stack = 8192;                      /* Datalight C */
  13. #endif
  14.  
  15. #if BORLAND
  16. unsigned _stklen = 8192;
  17. #endif
  18.  
  19. #if __TSC__
  20. #define MAXWIN 50                       /* TopSpeed C */
  21. #else
  22. #define MAXWIN 100                      /* for 100 windows */
  23. #endif
  24.  
  25. WINDOWPTR wins[MAXWIN];                 /* DONT INCREASE IN SMALL MODEL */
  26.  
  27. unsigned blue = BLUE;                   /* remap for mono */
  28.  
  29. /*
  30. ** Prototypes to keep the new ANSI Compilers Happy
  31. */
  32.  
  33. #if BORLAND | WATCOM | MSC
  34. int main(int argc, char **argv);
  35. int dedemo(void);
  36. int pddemo(void);
  37. int dotelecom(int ch);
  38. int dosetup(int ch);
  39. int dofileman(int ch);
  40. int dooutput(int ch);
  41. int dorun(int ch);
  42. int doedit(int ch);
  43. int nap(int ticks);
  44. int hiber(int seconds);
  45. int chkesc(void);
  46. int paktc(void);
  47. #endif
  48.  
  49. main(argc,argv)
  50. int argc;
  51. char *argv[];
  52. {
  53. WINDOWPTR     w2, w3;                   /* a few windows */
  54. WINDOWPTR tw1, tw2, tw3;                /* and a few more */
  55.  
  56. WINDOWPTR wn_qpopup();                  /* function returns WP */
  57. int i,j;                                /* scratch integers */
  58. int t50rib;                             /* top 50 atrib */
  59. int watrib,batrib;                      /* scratch atributes */
  60. int rv;                                 /* for popup */
  61. int row,col;                            /* for 100 windows */
  62.  
  63. MOUSEPTR mm;                            /* my mouse ptr */
  64. int mstat, mclik, mrow, mcol;           /* mouse stuff */
  65.  
  66.   static struct pmenu m1 = {
  67.     00, FALSE, 00,
  68.     00, 00, {
  69.     01, 02, "Presenting", 0,
  70.     99, 99, "",99 }
  71.   };
  72.  
  73.   static struct pmenu m2 = {
  74.     00, FALSE, 00,
  75.     00, 00, {
  76.     01, 02, "The", 0,
  77.     03, 02, "W i n d o w   B O S S", 0,
  78.     05, 02, "Fast - Easy - Windows", 0,
  79.     07, 02, "for the C Language", 0,
  80.     99, 99, "",99 }
  81.   };
  82.  
  83.   static struct pmenu intelc = {
  84.     00, FALSE, 00,
  85.     02, 06, {
  86.     01, 02, "         Intellicom", 0,
  87.     02, 02, "        Quick - Help", 0,
  88.     04, 05, "1 General Information  ", 1,
  89.     05, 05, "2 Terminal Mode Options", 2,
  90.     06, 05, "3 XMODEM File Send     ", 3,
  91.     07, 05, "4 XMODEM File Receive  ", 4,
  92. #if MSC | DLC | CI86 | LC3
  93.      8, 05, "5 CompuServe Exec Mode ", 5,
  94. #else
  95.     08, 05, "5 CompuServe Exec Mode ", 5,
  96. #endif
  97.     10, 02, "Press: ESC to quit or Cursor", 0,
  98.     11, 02, " Keys to Position Cursor then", 0,
  99.     12, 02, " press RETURN for MORE info.", 0,
  100.     99, 99, "",99 }
  101.   };
  102.  
  103. if(argc > 2) wn_dmaflg=FALSE;         /* for testing bios access */
  104.   if(wns_mtflg == 7) blue = BLACK;      /* remap if mono */
  105.   if(argc > 1) wn_dmode(PAINT);         /* pretend CGA */
  106.  
  107.   wn_init();                            /* save entry screen */
  108.  
  109.   batrib = v_setatr(WHITE,BLACK,0,BOLD);/* set border atrib */
  110.   watrib = v_setatr(WHITE,RED,0,0);     /* make it american */
  111.   w2 = wn_qpopup(0,0,0,16,3,watrib,batrib,&m1);
  112.   for(i=1; i<11; i++)                   /* move it into place */
  113.     w2 = wn_move(w2, i, i*2);
  114.  
  115.   hiber(1);                             /* wait 1 second (aprx) */
  116.  
  117.   batrib = v_setatr(RED,WHITE,0,BOLD);  /* set border atrib */
  118.   watrib = v_setatr(blue,WHITE,0,BOLD); /* make this american too */
  119.   w3 = wn_qpopup(0,0,0,30,9,watrib|BOLD,batrib,&m2);
  120.   for(i=1; i<8; i++)                    /* move into place */
  121.     w3 = wn_move(w3,i,6*i);             /* move into place */
  122.  
  123.   hiber(5);                             /* reading time.. */
  124.  
  125.   wn_clr(w3);
  126.   wn_title(w3," PLEASE NOTE ");
  127.   wn_printf(w3,"\n");
  128.   wn_printf(w3,"This demo contains reading\n");
  129.   wn_printf(w3,"time delays that you can\n");
  130.   wn_printf(w3,"shorten by pressing the ESC\n");
  131.   wn_printf(w3,"key.\n\n");
  132.   wn_printf(w3,"Press any key to continue...");
  133.   paktc();
  134.  
  135.   wn_close(w3);                         /* close a couple */
  136.   hiber(1);
  137.   wn_close(w2);
  138.   hiber(1);
  139.  
  140.   watrib = v_setatr(WHITE,BLACK,0,BOLD);
  141.   for(i=0; i<25; i++) {                 /* build the back drop */
  142.     v_locate(0,i,0);                    /* position cursor */
  143.     v_wca(0, 0xb0, watrib, 80);         /* the fast way */
  144.   }
  145.   v_hidec();                            /* hide the cursor */
  146.  
  147.   watrib = v_setatr(WHITE,BLACK,0,0);   /* window attribute */
  148.   batrib = v_setatr(blue,WHITE,0,0);    /* border attribute */
  149.   w3 = wn_open(800,1,9,60,21,watrib,batrib);
  150.   w3->bstyle |= BOLD;                   /* toggle bold on then off */
  151.   wn_title(w3," The Window BOSS for C ");
  152.   w3->bstyle ^= BOLD;
  153.   wn_puts(w3,1,1,"The Window BOSS puts YOU in control of the most important");
  154.   wn_puts(w3,2,1,"sophisticated state-of-the-art screen handling techniques");
  155.   wn_puts(w3,3,1,"available today.  Pop-up windows, pull-down menus, status ");
  156.   wn_puts(w3,4,1,"lines and context sensitive help functions are a breeze ");
  157.   wn_puts(w3,5,1,"to implement!  Your program automatically senses the ");
  158.   wn_puts(w3,6,1,"video card installed and ALL your video output takes ");
  159.   wn_puts(w3,7,1,"place with no snow, no flicker, and no delay. But best of");
  160.   wn_puts(w3,8,1,"all, The Window BOSS is available as SHAREWARE software!");
  161.   wn_puts(w3,9,1," ");
  162.   wn_puts(w3,10,1,"The Window BOSS is available for compilers from Microsoft,");
  163.   wn_puts(w3,11,1,"Borland, WATCOM, Mix, JPI, Zortech, and Lattice. Users who");
  164.   wn_puts(w3,12,1,"register receive complete documentation, all source code,");
  165.   wn_puts(w3,13,1,"and support for all your compilers memory models!!    ");
  166.   wn_puts(w3,14,1," ");
  167.   wn_puts(w3,15,1,"I challenge you to compare: The Window BOSS is faster");
  168.   wn_puts(w3,16,1,"and easier to use than most commercial products on the");
  169.   wn_puts(w3,17,1,"market today! Others seem to agree too! Browse through");
  170.   wn_puts(w3,18,1,"the Cosmetic Surgery article in the September '91 issue");
  171.   wn_puts(w3,19,1,"of Computer Language Magazine for starters....");
  172.   hiber(30);
  173.  
  174.   wn_clr(w3);
  175.   wn_puts(w3, 1,1,"Tim Parker's column in the February 87 issue of Computer ");
  176.   wn_puts(w3, 2,1,"Language stated \"the ease of use will cause some ");
  177.   wn_puts(w3, 3,1,"programmers to go overboard with windows\", and \"if you ");
  178.   wn_puts(w3, 4,1,"are a die-hard C programmer looking for a useful, ");
  179.   wn_puts(w3, 5,1,"license-free product, this is it\".");
  180.   wn_puts(w3, 6,1," ");
  181.   wn_puts(w3, 7,1,"Hardin Bothers' column in the June 88 issue of PC ");
  182.   wn_puts(w3, 8,1,"Resource stated \"Within its domain, The Window BOSS is ");
  183.   wn_puts(w3, 9,1,"as useful and as powerful as any C library I've used\". ");
  184.   wn_puts(w3,10,1,"\"The Window BOSS owes much of its power to its ");
  185.   wn_puts(w3,11,1,"uncluttered organization. Although the product supports ");
  186.   wn_puts(w3,12,1,"five C Compilers - Microsoft C, Lattice C, Borland's ");
  187.   wn_puts(w3,13,1,"Turbo C, Computer Innovations CI86, and Datalight C - it ");
  188.   wn_puts(w3,14,1,"does it with a minimum of fuss\".");
  189.   wn_puts(w3,15,1," ");
  190.   wn_puts(w3,16,1,"The BOSS is currently being used by dozens of Fortune ");
  191.   wn_puts(w3,17,1,"500 Companies, numerous universities, and discriminating ");
  192.   wn_puts(w3,18,1,"\"C\" programmers around the world!  Haven't you waited ");
  193.   wn_puts(w3,19,1,"long enough?");
  194.   hiber(30);
  195.  
  196.  
  197.   wn_clr(w3);
  198.   wn_puts(w3, 1,1,"  Psst...");
  199.   wn_puts(w3, 2,1,"  ");
  200.   wn_puts(w3, 3,1,"    The Window BOSS is one of ");
  201.   wn_puts(w3, 4,1,"               PC-SIG's TOP 50 Best Selling Programs");
  202.   wn_puts(w3, 5,1,"  ");
  203.   wn_puts(w3, 6,1,"              ██████     █████      █████ ");
  204.   wn_puts(w3, 7,1,"                ██       █   █      █   █");
  205.   wn_puts(w3, 8,1,"                ██       █   █      █████");
  206.   wn_puts(w3, 9,1,"                ██       █   █      ██");
  207.   wn_puts(w3,10,1,"                ██       █████      ██");
  208.   wn_puts(w3,11,1,"  ");
  209.   wn_puts(w3,12,1,"                   █████      █████");
  210.   wn_puts(w3,13,1,"                   █          █   █");
  211.   wn_puts(w3,14,1,"                   █████      █   █");
  212.   wn_puts(w3,15,1,"                       █      █   █");
  213.   wn_puts(w3,16,1,"                   █████      █████");
  214.   wn_puts(w3,17,1,"  ");
  215.   wn_puts(w3,18,1,"            Shareware Magazine Jan-Feb 1990");
  216.   wn_puts(w3,19,1,"  ");
  217.   for(j=0; j<=WHITE; j++) {
  218.     t50rib = v_setatr(WHITE,j,0,BOLD);
  219.     wn_natrib(w3,t50rib);
  220.   }
  221.   wn_dmode(PAINT);
  222.   wn_natrib(w3,watrib);
  223.   wn_dmode(FLASH);
  224.   hiber(5);
  225.  
  226.   watrib = v_setatr(WHITE,blue,0,0);    /* window attribute */
  227.   batrib = v_setatr(RED,WHITE,0,BOLD);  /* border attribute */
  228.   w2 = wn_open(0,5,5,50,10,watrib,batrib);
  229.   if(!w2) exit(1);                      /* yes.. it should be better */
  230.   wn_puts(w2,0,0," Simple text output is very fast");
  231.   wn_puts(w2,1,0," and snow free.");
  232.   wn_puts(w2,3,0," Watch this....");
  233.   hiber(3);
  234.   wn_clr(w2);                           /* clear it then fill it */
  235.   for(i=0; i<10; i++)
  236.     wn_puts(w2,i,0," Very fast screen output - no snow!");
  237.   hiber(5);
  238.   wn_clr(w2);                           /* do it again */
  239.   for(i=0; i<10; i++)
  240.     wn_puts(w2,i,0," Another window full of fast text.");
  241.   hiber(5);
  242.  
  243.   wn_clr(w2);
  244.   wn_printf(w2," The BOSS also supports a printf function!\n");
  245.   wn_printf(w2," Its as simple as:\n\n");
  246.   wn_printf(w2," \twn_printf(wn,\"%%d\\n\",i);\n\n");
  247.   wn_printf(w2," to print a value in a window.\n\n");
  248.   wn_printf(w2," Scrolling works too\n");
  249.   wn_printf(w2," Lets count (slowly) to 10...\n");
  250.   wn_sync(w2, TRUE);
  251.   hiber(10);
  252.   for(i=1;i<11;i++) {
  253.     wn_printf(w2," The count is: %d\n", i);
  254.     nap(5);
  255.   }
  256.   wn_printf(w2," Ok, lets see what it looks like at\n");
  257.   wn_printf(w2," full speed.. (counting to 25)\n");
  258.   hiber(5);
  259.   for(i=1;i<26;i++)
  260.     wn_printf(w2," The count is: %d\n", i);
  261.   hiber(5);                             /* reading time */
  262.   wn_sync(w2, FALSE);
  263.   v_hidec();
  264.  
  265.   wn_clr(w2);
  266.   wn_putsa(w2,0,0," Full color support is provided.",WHITE<<4);
  267.   for(i=1; i<6; i++)
  268.     wn_putsa(w2,i,0, " Add a little color to your life.",WHITE<<4|i);
  269.   wn_putsa(w2,6,0," As is window movement....watch...",WHITE<<4|BLACK);
  270.   hiber(5);
  271.  
  272.   for(i=0; i<13; i++)                   /* move the window around */
  273.     w2 = wn_move(w2, i, i*2);
  274.   hiber(5);
  275.   wn_printf(w2,"\n Lets put it back where we started...\n");
  276.   hiber(3);
  277.   w2 = wn_move(w2,5,5);
  278.   wn_printf(w2," Now, lets add a title to our window!\n");
  279.   hiber(3);
  280.   w2->bstyle |= BOLD;
  281.   wn_title(w2," Pretty Powerful Stuff ");
  282.   w2->bstyle ^= BOLD;
  283.   hiber(5);
  284.  
  285. /* ============================= Tiled Window Stuff ===================== */
  286.  
  287.   wn_printf(w2," Tiled windows are supported\n");
  288.   wn_printf(w2," Lets add three.\n");
  289.   hiber(5);
  290.  
  291.   wn_sbit=FAST;
  292.   tw1 = wn_open(510,3,5,40,10, RED<<4|YELLOW|BOLD, RED<<4|WHITE|BOLD);
  293.   wn_sync(tw1,TRUE);
  294.   wn_printf(tw1,"ONE\n");
  295.   tw2 = wn_open(510,6,8,40,10, blue<<4|WHITE|BOLD, blue<<4|GREEN|BOLD);
  296.   wn_sync(tw2,TRUE);
  297.   wn_printf(tw2,"TWO\n");
  298.   tw3 = wn_open(510,9,11,40,10,GREEN<<4|WHITE|BOLD, GREEN<<4|WHITE|BOLD);
  299.   wn_sync(tw3,TRUE);
  300.   wn_printf(tw3,"THREE\n");
  301.   wn_printf(tw3," Press a key and watch TWO move\n");
  302.   wn_printf(tw3," To the top!!\n");
  303.   v_getch();
  304.  
  305.   wn_activate(tw2);
  306.   wn_printf(tw2," Press a key and watch THREE move\n");
  307.   wn_printf(tw2," To the top!!\n");
  308.   v_getch();
  309.   wn_activate(tw3);
  310.   wn_printf(tw3," Press a key and watch ONE move\n");
  311.   wn_printf(tw3," To the top!!\n");
  312.   v_getch();
  313.   wn_activate(tw1);
  314.  
  315.   wn_printf(tw1, " Ok..Press a key\n");
  316.   wn_printf(tw1, " and we will continue with the show!");
  317.   v_getch();
  318.  
  319.   wn_close(tw1);
  320.   wn_close(tw3);
  321.   wn_close(tw2);
  322.  
  323.   wn_clr(w2);
  324.   wn_printf(w2," 100 are as easy as 3!!\n");
  325.   wn_printf(w2," Press any key please..\n");
  326.   v_getch();
  327.  
  328.   for (i = 0; i < MAXWIN; i++) {
  329.      row = (rand() % 12) +3;
  330.      col = (rand() % 62) +2;
  331.      batrib = rand() % 16;
  332.      watrib = rand() % 128;
  333.      if(wns_mtflg == 7) {
  334.        batrib = v_setatr(BLACK,WHITE,0,BOLD);
  335.        watrib = v_setatr(BLACK,WHITE,0,BOLD);
  336.      }
  337.      wins[i] = wn_open(0,row,col,11,7,watrib, batrib);
  338.      if(!wins[i]) {
  339.        v_locate(0,0,0);
  340.        v_cls(NORMAL);
  341.        printf("wn_open failed...reduce MAXWIN!!\n");
  342.        exit(1);
  343.      }
  344.      wn_printf(wins[i],"%d",i);
  345.   }
  346.   hiber(5);
  347.  
  348.   wn_clr(w2);
  349.   wn_printf(w2," Lets activate the bottom 10 one at a time.\n");
  350.   wn_printf(w2," When you hear the beep press a key...\n");
  351.   hiber(5);
  352.  
  353.   paktc();
  354.   for(i=0;i<10;i++) {
  355.     wn_printf(wins[i]," Activated!\n");
  356.     paktc();
  357.   }
  358.  
  359.   wn_clr(w2);
  360.   wn_printf(w2, " Truly Powerful Stuff!!\n");
  361.   wn_printf(w2, " Ok..Press a key\n");
  362.   wn_printf(w2, " and we will SLOWLY close all 100 windows by\n");
  363.   wn_printf(w2, " floating each window to the top of the stack\n");
  364.   wn_printf(w2, " and restoring the image that existed prior to\n");
  365.   wn_printf(w2, " the window being opened. Concurrently, all \n");
  366.   wn_printf(w2, " other hidden images will be adjusted to reflect\n");
  367.   wn_printf(w2, " the fact that a window has vanished!!\n");
  368.   v_getch();
  369.  
  370.   for(i=MAXWIN-1; i>=0; i--) {
  371.     wn_printf(wins[i]," Closing\n");
  372.     nap(2);
  373.     if(!wn_close(wins[i])) {
  374.       v_cls(7);
  375.       v_locate(0,0,0);
  376.       printf("wn_close failed!\n");
  377.       exit(1);
  378.     }
  379.   }
  380.  
  381.   wn_sbit=SLOW;
  382.  
  383. /* ========================= Popup & Help Stuff ========================= */
  384.  
  385.   wn_clr(w2);
  386.   wn_printf(w2," Popup Menus are a breeze.\n\n");
  387.   wn_printf(w2," Watch....");
  388.   hiber(2);
  389.   if(!wn_hlinit(0,0,78,23,BLUE<<4 | WHITE, BLUE<<4 | WHITE,"intelc")) {
  390.     v_locate(0,0,0);
  391.     printf("wn_hlinit failed!\n");
  392.     exit(0);
  393.   }
  394.   do {
  395.     rv = wn_popup(0,0,0,33,14, WHITE<<4|BLACK, blue<<4|WHITE, &intelc,FALSE);
  396.  
  397.     switch (rv) {                       /* dispatch */
  398.       case 1:
  399.         wn_help("%general information%");
  400.         break;
  401.       case 2:
  402.         wn_help("%terminal%");
  403.         break;
  404.       case 3:
  405.         wn_help("%checksum xmit1%");
  406.         break;
  407.       case 4:
  408.         wn_help("%checksum recv1%");
  409.         break;
  410.       case 5:
  411.         wn_help("%cistty1%");
  412.         break;
  413.       case 99:
  414.       default:
  415.         break;
  416.     }
  417.   } while(rv !=99);
  418.  
  419. /***************************** Pulldown Stuff *****************************/
  420.  
  421.   wn_clr(w2);                           /* setup for pulldown */
  422.   wn_printf(w2," Pulldown Menus are easy too!!\n\n");
  423.   wn_printf(w2," Watch....");
  424.   hiber(2);
  425.   pddemo();                             /* pulldown sample */
  426.  
  427. /***************************** Data Entry Stuff **************************/
  428.  
  429.                                         /* set up for data entry */
  430.   wn_clr(w2);
  431.   wn_printf(w2," Naturally, The Window BOSS fully supports\n");
  432.   wn_printf(w2," data entry in windows!!\n\n");
  433.   wn_printf(w2," Lets try a small sample ....");
  434.   hiber(5);
  435.   dedemo();                             /* do the data entry demo */
  436.  
  437. /**************************** Summary Stuff *******************************/
  438.  
  439.   wn_clr(w2);                           /* clear the window */
  440.   w2->bstyle |= BOLD;                   /* toggle bold on then off */
  441.   wn_title(w2," The Window BOSS for C ");
  442.   w2->bstyle ^= BOLD;
  443.   wn_printf(w2,"\n\n  The following is a quick summary\n");
  444.   wn_printf(w2,"  of SOME of the functions available...");
  445.   hiber(4);
  446.  
  447.   wn_help("%bossinfo%");                /* provide some details */
  448.  
  449.   wn_clr(w2);                           /* and now the credits */
  450.   wn_printf(w2,"\n\n\n");
  451.   wn_printf(w2,"                  The Window BOSS\n");
  452.   wn_printf(w2,"             Copyright (c) 1985 - 1990\n");
  453.   wn_printf(w2,"              Philip  A. Mongelluzzo\n");
  454.   wn_printf(w2,"                 273 Windy Drive\n");
  455.   wn_printf(w2,"              Waterbury, Conn  06705\n");
  456.  
  457.   wn_printf(w2,"\n\t\t\t\tThats all folks...\n\n");
  458.  
  459.   hiber(10);                            /* all done ! */
  460.   wn_close(w2);
  461.   wn_close(w3);
  462.   wn_exit();                            /* restore entry screen */
  463.  
  464. /**************************** Mouse Stuff *********************************/
  465.  
  466.  
  467.   mm = mo_reset();                      /* init mouse */
  468.  
  469.   if(mm) {                              /* mouse exists */
  470.     printf("Simple Mouse Demo - press any key to continue...");
  471.     v_getch();
  472.     v_cls(NORMAL);                      /* clear the screen */
  473.     v_locate(0,0,0);                    /* locate the cursor */
  474.     printf("Mouse exists with %d buttons.\n", mo_nbutt(mm));
  475.     printf("Move mouse, randomly click right button, click left to end.\n");
  476.     mo_motion(mm);                      /* set motion counters */
  477.     mo_setptr(mm, 0x1E, NORMAL);        /* set mouse pointer style */
  478.     mo_reigon(mm, 0, 0, 80, 25);        /* set mouse "window" */
  479.     mo_show(mm);                        /* show the critter */
  480.  
  481.     do {                                /* click tests */
  482.       mo_press(mm, MO_RIGHT, &mstat, &mclik, &mrow, &mcol);
  483.       if(mclik > 0) {                   /* right button PRESSED ? */
  484.         v_locate(0,3,0);                /* display info if so */
  485.         printf("Right button @ %03d,%03d\n", mrow, mcol);
  486.       }
  487.       mo_release(mm, MO_LEFT, &mstat, &mclik, &mrow, &mcol);
  488.       if(mclik > 0) {                   /* left RELEASED ? */
  489.         v_locate(0,4,0);
  490.         printf("Left  button @ %03d,%03d\n", mrow, mcol);
  491.       }
  492.     } while (mclik != 1);
  493.  
  494.     v_locate(0,5,0);
  495.     printf("Roll test... move mouse, click left or right for next test.\n");
  496.     do {                                /* rolling test */
  497.       mo_rcpos(mm, &mstat, &mrow, &mcol);
  498.       v_locate(0,6,0);
  499.       printf("Mouse @ %03d,%03d\n", mrow, mcol);
  500.     } while (!mstat);
  501.  
  502.     mo_wait(mm);                        /* wait for mouse to settle */
  503.     v_cls(NORMAL);                      /* clear screen */
  504.     v_locate(0,0,0);                    /* locate cursor */
  505.     printf("Mouse fence test\n");
  506.     printf("Just try n' get out!! (click)\n");
  507.     mo_locate(mm, 5, 0);                /* home mouse .. almost */
  508.     mo_reigon(mm, 5, 0, 10, 10);        /* set mouse window size */
  509.  
  510.     do {                                /* exit on button release */
  511.       mo_release(mm, MO_LEFT,  &mstat, &mclik, &mrow, &mcol);
  512.       if(mclik)
  513.         break;
  514.       mo_release(mm, MO_RIGHT, &mstat, &mclik, &mrow, &mcol);
  515.       if(mclik)
  516.         break;
  517.     } while (TRUE);
  518.  
  519.     v_cls(NORMAL);                      /* clear screen */
  520.     v_locate(0,0,0);                    /* home cursor */
  521.     mo_hide(mm);                        /* hide mouse */
  522.     mm = mo_reset();                    /* reset mouse */
  523.     exit(0);                            /* finito */
  524.   }
  525.   exit(0);
  526. }
  527.  
  528. /************************* Data Entry Demo Code ***************************/
  529.  
  530. dedemo()                                /* data entry demo */
  531. {
  532. WINDOWPTR wn;                           /* window pointer */
  533. WIFORM frm;                             /* form pointer */
  534. static struct db {                      /* record layout */
  535.   char  date[10];                       /* date string */
  536.   int   month,day,year;                 /* date numerics */
  537.   char  time[10];                       /* time string */
  538.   int   thrs,tmin,tsec;                 /* time numerics */
  539.   char  name[32];                       /* name */
  540.   char  adr[32];                        /* street address */
  541.   char  city[17];                       /* city */
  542.   char  st[4];                          /* state */
  543.   char  zip[8];                         /* zip */
  544.   char  phone[18];                      /* phone string */
  545.   int   ac, nnx, num;                   /* phone numerics */
  546.   char  age[4];                         /* age */
  547.   int   old;                            /* age numeric */
  548. } rec;
  549. unsigned atrib;                         /* data entry field atribute */
  550. char *emsg1,*emsg2,*emsg3;              /* error msg ptr */
  551. char fchar;                             /* fill character */
  552.  
  553.                                         /* open window */
  554.   wn = wn_open(0,10,10,42,9,(BLUE<<4|YELLOW|BOLD),(BLUE<<4|WHITE|BOLD));
  555.   if(!(wn)) {                           /* errors ?? */
  556.     printf("wn_open failed!!\n");       /* tell of woe... */
  557.     exit(1);                            /* and die */
  558.   }
  559.   wn_title(wn," Sample Data Entry Form ");
  560.  
  561.   frm = wn_frmopn(11);                  /* form open for 10 fields */
  562.   if(!frm) {                            /* errors ?? */
  563.     printf("wn_frmopn failed!!\n");     /* tell of woe... */
  564.     exit(1);                            /* and die */
  565.   }
  566.  
  567.   atrib = (BLUE<<4) | WHITE | BOLD;     /* field attribute */
  568.   *rec.date = NUL;                      /* set edit buffer to zip */
  569.   *rec.time = NUL;                      /* set edit buffer to zip */
  570.   *rec.adr = NUL;                       /* set edit buffer to zip */
  571.   *rec.city = NUL;                      /* set edit buffer to zip */
  572.   *rec.st = NUL;                        /* set edit buffer to zip */
  573.   *rec.zip = NUL;                       /* set edit buffer to zip */
  574.   *rec.phone = NUL;                     /* set edit buffer to zip */
  575.   *rec.age = NUL;                       /* set edit buffer to zip */
  576.  
  577.   emsg1 = "Invalid date, press any key to continue...";
  578.   emsg2 = "Invalid time, press any key to continue...";
  579.   emsg3 = "Age must be between 1 and 99, press any key to continue...";
  580.  
  581.   fchar = '_';
  582.  
  583.   wn_gdate (SET,frm,0, wn,1,1, "Date: ",atrib,fchar,&rec.month,&rec.day,&rec.year,rec.date,NSTR,emsg1);
  584.   wn_gtime (SET,frm,1, wn,1,23,"Time: ",atrib,fchar,&rec.thrs,&rec.tsec,&rec.tmin, rec.time,NSTR,emsg2);
  585.   wn_gtext (SET,frm,2, wn,3,1, "Name: ",atrib,fchar,30,rec.name,NSTR,NSTR);
  586.   wn_gtext (SET,frm,3, wn,4,1, "Addr: ",atrib,fchar,30,rec.adr,NSTR,NSTR);
  587.   wn_gtext (SET,frm,4, wn,5,1, "City: ",atrib,fchar,15,rec.city,NSTR,NSTR);
  588.   wn_gutext(SET,frm,5, wn,5,23,  "ST: ",atrib,fchar,2,rec.st,NSTR,NSTR);
  589.   wn_gtext (SET,frm,6, wn,5,31, "Zip: ",atrib,fchar,5,rec.zip,NSTR,NSTR);
  590.   wn_gphone(SET,frm,7, wn,7,1, "Tele: ",atrib,fchar,&rec.ac,&rec.nnx,&rec.num,rec.phone,NSTR,NSTR);
  591.   wn_gint  (SET,frm,8, wn,7,23,"Age : ",atrib,fchar,&rec.old,2,1,99,rec.age,NSTR,emsg3);
  592.  
  593.   if(!wn_frmget(frm)) {                 /* get (read) form */
  594.     v_cls(7);                           /* die if errors !! */
  595.     v_locate(0,0,0);
  596.     printf("Memory Corruption Error!\n");
  597.     exit(1);
  598.   }
  599.  
  600.   wn_clr(wn);                           /* clear window & display data */
  601.   wn_printf(wn,"Data entered was:\n");
  602.   wn_printf(wn,"Date: %02d/%02d/%02d  ", rec.month, rec.day, rec.year);
  603.   wn_printf(wn,"Time: %02d:%02d:%02d\n", rec.thrs, rec.tmin, rec.tsec);
  604.   wn_printf(wn,"Name: %s\n",rec.name);
  605.   wn_printf(wn,"Adr:  %s\n",rec.adr);
  606.   wn_printf(wn,"City: %s ST: %s Zip: %s\n",rec.city, rec.st, rec.zip);
  607.   wn_printf(wn,"Tele: (%03d) %03d-%04d\n", rec.ac, rec.nnx, rec.num);
  608.   wn_printf(wn,"Age:  %2d\n",rec.old);
  609.   wn_printf(wn,"\nPress any key to continue..");
  610.   v_getch();
  611.  
  612.   wn_frmcls(frm);                       /* close for */
  613.   wn_close(wn);                         /* close window */
  614.   return(NULL);                         /* keep the compilers happy */
  615. }
  616.  
  617. /*********************** Pulldown Menu Code *******************************/
  618.  
  619. pddemo()
  620. {
  621. WINDOWPTR w0;                           /* back drop */
  622. int fini;                               /* finished flag */
  623. int watrib,batrib;                      /* scratch atributes */
  624. int rv;                                 /* for popup */
  625. int currch;                             /* current choice */
  626.  
  627. static struct pmenu mainbar = {         /* menu bar */
  628.   00, FALSE, 00,
  629.   00, 06, {
  630.   00, 05, "EDIT", 1,
  631.   00, 15, "RUN", 2,
  632.   00, 25, "OUTPUT", 3,
  633.   00, 35, "FILE MANAGER", 4,
  634.   00, 50, "SETUP", 5,
  635.   00, 60, "TELECOM", 6,
  636.   00, 70, "QUIT", 7,
  637.   99, 99, "",99 }
  638. };
  639.  
  640. static struct pmenu pdedit = {          /* Edit Pulldown */
  641.   00, FALSE, 00,
  642.   00, 05, {
  643.   00, 00, "Edit existing data file      ", 1,
  644.   01, 00, "Edit new data file           ", 2,
  645.   02, 00, "Pull up data file template   ", 3,
  646.   03, 00, "Select data file group       ", 4,
  647.   04, 00, "Print all data files         ", 5,
  648.    5, 00, "Save                         ", 6,
  649.   99, 99, "",99 }
  650. };
  651.  
  652. static struct pmenu pdrun = {           /* Run Pulldown */
  653.   00, FALSE, 00,
  654.   00, 01, {
  655.   00, 00, "Single  ", 1,
  656.   01, 00, "Batch   ", 2,
  657.   99, 99, "",99 }
  658. };
  659.  
  660. static struct pmenu pdoutput = {        /* Output Pulldown */
  661.   00, FALSE, 00,
  662.   00, 02, {
  663.   00, 00, "View    ", 1,
  664.   01, 00, "Print   ", 2,
  665.   02, 00, "Graphics", 3,
  666.   99, 99, "",99 }
  667. };
  668.  
  669. static struct pmenu pdfileman = {       /* File Manager Pulldown */
  670.   00, FALSE, 00,
  671.   00, 06, {
  672.   00, 00, "Rename  ", 1,
  673.   01, 00, "Copy    ", 2,
  674.   02, 00, "Delete  ", 3,
  675.   03, 00, "Chdir   ", 4,
  676.   04, 00, "Editor  ", 5,
  677.   05, 00, "Print   ", 6,
  678.   06, 00, "DOS     ", 7,
  679.   99, 99, "",99 }
  680. };
  681.  
  682. static struct pmenu pdsetup = {         /* Setup Pulldown */
  683.   00, FALSE, 00,
  684.   00, 02, {
  685.   00, 00, "Colors  ", 1,
  686.   01, 00, "Printers", 2,
  687.   02, 00, "Plotters", 3,
  688.   99, 99, "",99 }
  689. };
  690.  
  691. static struct pmenu pdtelecom = {       /* Telcomm Pulldown */
  692.   00, FALSE, 00,
  693.   00, 01, {
  694.   00, 00, "No      ", 1,
  695.   01, 00, "Yes     ", 2,
  696.   99, 99, "",99 }
  697. };
  698.  
  699. static struct pmenu pdquit = {          /* Quit Pulldown */
  700.   00, FALSE, 00,
  701.   00, 01, {
  702.   00, 00, "No      ", 1,
  703.   01, 00, "Yes     ", 2,
  704.   99, 99, "",99 }
  705. };
  706.  
  707.   fini = FALSE;                         /* say we are not done */
  708.   w0 = wn_open(1000,0,0,80,25,NVIDEO,NVIDEO);   /* save entry screen */
  709.   if(!w0) return(NULL);                 /* less than graceful exit */
  710.  
  711.   wn_puts(w0,22,0, "Use cursor keys to highlight, Enter key to select");
  712.   wn_puts(w0,23,0, "Press ESC to return to Menu Bar");
  713.   wn_puts(w0,24,0, "To continue the demo ... Select Quit from menu bar, then YES from pulldown");
  714.  
  715.   batrib = v_setatr(BLACK,WHITE,0,0);   /* set border atrib */
  716.   watrib = v_setatr(BLACK,WHITE,0,0);   /* keep it simple too */
  717.  
  718.   do {                                  /* Pull down Loop */
  719.     rv = wn_popup(0,0,0,78,01, watrib, batrib, &mainbar, FALSE);
  720.     switch (rv) {                       /* dispatch based on mainbar */
  721.       case 1:                           /* Edit */
  722.         do {
  723.           currch = wn_popup(00,03, 5, 29, 6, watrib, batrib, &pdedit, FALSE);
  724.           doedit(currch);
  725.         } while (currch != 99);
  726.         break;
  727.       case 2:                           /* Run */
  728.         do {
  729.           currch = wn_popup(00,03, 15, 8, 2, watrib, batrib, &pdrun, FALSE);
  730.           dorun(currch);
  731.         } while (currch != 99);
  732.         break;
  733.       case 3:                           /* Output */
  734.         do {
  735.           currch = wn_popup(00,03, 25, 8, 3, watrib, batrib, &pdoutput, FALSE);
  736.           dooutput(currch);
  737.         } while (currch != 99);
  738.         break;
  739.       case 4:                           /* Filemanager */
  740.         do {
  741.           currch = wn_popup(00,03, 35, 8, 7, watrib, batrib, &pdfileman, FALSE);
  742.           dofileman(currch);
  743.         } while (currch != 99);
  744.         break;
  745.       case 5:                           /* Setup */
  746.         do {
  747.           currch = wn_popup(00,03, 50, 8, 3, watrib, batrib, &pdsetup, FALSE);
  748.           dosetup(currch);
  749.         } while (currch !=99);
  750.         break;
  751.       case 6:
  752.         do {
  753.           currch = wn_popup(00,03, 60, 8, 2, watrib, batrib, &pdtelecom, FALSE);
  754.           dotelecom(currch);
  755.         } while (currch != 99);
  756.         break;
  757.       case 7:                           /* quit */
  758.         currch = wn_popup(00,03, 70, 8, 2, watrib, batrib, &pdquit, TRUE);
  759.         if(currch == 2) {
  760.           fini = TRUE;
  761.           mainbar.winopn = FALSE;
  762.           wn_close(mainbar.wpsave);
  763.         }
  764.         break;
  765.       case 99:
  766.       default:
  767.         break;
  768.     }
  769.   } while(!fini);                       /* do till fini == TRUE */
  770.   wn_close(w0);
  771. }
  772.  
  773. dotelecom(ch)                           /* telcomm */
  774. int ch;
  775. {
  776. WINDOWPTR wn;
  777. static char *msg = "Telcom";
  778.  
  779.   if(ch == 99) return(NULL);
  780.   wn=wn_open(0,15,10,60,1,NVIDEO,NVIDEO);
  781.   wn_printf(wn,"  %s choice: %d,  Press any key to continue...............",msg,ch);
  782.   v_getch();
  783.   wn_close(wn);
  784. }
  785.  
  786. dosetup(ch)                             /* setup */
  787. int ch;
  788. {
  789. WINDOWPTR wn;
  790. static char *msg = "Setup";
  791.  
  792.   if(ch == 99) return(NULL);
  793.   wn=wn_open(0,15,10,60,1,NVIDEO,NVIDEO);
  794.   wn_printf(wn,"  %s choice: %d,  Press any key to continue...............",msg,ch);
  795.   v_getch();
  796.   wn_close(wn);
  797. }
  798.  
  799. dofileman(ch)                           /* file manager */
  800. int ch;
  801. {
  802. WINDOWPTR wn;
  803. static char *msg = "File";
  804.  
  805.   if(ch == 99) return(NULL);
  806.   wn=wn_open(0,15,10,60,1,NVIDEO,NVIDEO);
  807.   wn_printf(wn,"  %s choice: %d,  Press any key to continue...............",msg,ch);
  808.   v_getch();
  809.   wn_close(wn);
  810. }
  811.  
  812. dooutput(ch)                            /* output manager */
  813. int ch;
  814. {
  815. WINDOWPTR wn;
  816. static char *msg = "Output";
  817.  
  818.   if(ch == 99) return(NULL);
  819.   wn=wn_open(0,15,10,60,1,NVIDEO,NVIDEO);
  820.   wn_printf(wn,"  %s choice: %d,  Press any key to continue...............",msg,ch);
  821.   v_getch();
  822.   wn_close(wn);
  823. }
  824.  
  825. dorun(ch)                               /* single/batch mngr */
  826. int ch;
  827. {
  828. WINDOWPTR wn;
  829. static char *msg = "Run Manager";
  830.  
  831.   if(ch == 99) return(NULL);
  832.   wn=wn_open(0,15,10,60,1,NVIDEO,NVIDEO);
  833.   wn_printf(wn,"  %s choice: %d,  Press any key to continue...............",msg,ch);
  834.   v_getch();
  835.   wn_close(wn);
  836. }
  837.  
  838. doedit(ch)                              /* edit mngr */
  839. int ch;
  840. {
  841. WINDOWPTR wn;
  842. static char *msg = "Edit";
  843.  
  844.   if(ch == 99) return(NULL);
  845.   wn=wn_open(0,15,10,60,1,NVIDEO,NVIDEO);
  846.   wn_printf(wn,"  %s choice: %d,  Press any key to continue...............",msg,ch);
  847.   v_getch();
  848.   wn_close(wn);
  849. }
  850.  
  851. /************************* Miscellaneous Code *****************************/
  852.  
  853.  
  854. nap(ticks)                              /* sleep a few clock ticks */
  855. int ticks;
  856. {
  857. unsigned long tc;
  858. unsigned long ts, te;
  859.  
  860.   ts = wns_gticks();                    /* get current tick count */
  861.   do {
  862.     if(chkesc()) return(NULL);
  863.     te = wns_gticks();
  864.     tc = te-ts;
  865.   } while (tc < (unsigned long)ticks);
  866. }
  867.  
  868. hiber(seconds)
  869. int seconds;
  870. {
  871.   nap(seconds * 18);
  872.   return(NULL);
  873. }
  874.  
  875. chkesc()                                /* check for ESC while napping */
  876. {
  877. int c;
  878.  
  879.   if(v_kstat()) {
  880.     c=v_getch() & 0x7f;
  881.     switch(c) {
  882.       case ESC:
  883.         return(TRUE);
  884.       case ETX:
  885.         v_cls(7);
  886.         v_locate(0,0,0);
  887.         exit(0);
  888.       default:
  889.         return(FALSE);
  890.     }
  891.   }
  892.   return(FALSE);
  893. }
  894.  
  895. paktc()                                 /* press any key to continue */
  896. {
  897.   v_wtty(0x07);                         /* beep */
  898.   v_getch();
  899.   return(NULL);
  900. }
  901.  
  902. /* End */
  903.